#include <stdio.h>  // for printf
#include <unistd.h> // for sleep
#include "hi_task.h"  // for hi_task_create
#include "ohos_init.h"  //for APP_FEATURE_INIT

static unsigned int Test; //任务id

/*任务的属性*/
const hi_task_attr MonitorTaskAttr_task = {
    .task_prio = 20, //任务优先级
    .stack_size = 4096, //任务分配内存大小
    .task_name = "test_task", //任务名称
};

/*任务执行函数*/
static hi_void *example_task(hi_void *data){
    while(1){
        sleep(2);
        printf("kp task example is running!\r\n");
    }
    return NULL;
}

hi_void task_demo()
{
    int ret;
    ret = hi_task_create(&Test, // task标识 //
        &MonitorTaskAttr_task,
        example_task, // task处理函数 //
        NULL); // task处理函数参数 //

    if (ret < 0) {
        printf("Create test task failed [%d]\r\n", ret);
        return;
    }
}

APP_FEATURE_INIT(task_demo);
